/**
 * Project Name:SimonFramework
 * File Name:ViewScaleType.java
 * Package Name:com.simon.framework.image.core.assist
 * Date:2016-5-19 下午3:53:14
 * Copyright (c) 2016, simon@cmonbaby.com All Rights Reserved.
 */
package com.cmonbaby.images.core.assist;

import android.widget.ImageView;

/**
 * <p>Author:      Simon
 * <p>QO:          8950764
 * <p>Email:       simon@cmonbaby.com
 * <p>WebSize:     https://www.cmonbaby.com
 * <p>Version:     1.0.0
 * <p>Date:        2020/12/29
 * <p>Description: 简化2种类
 */
public enum ViewScaleType {

    /**
     * Scale the image uniformly (maintain the image's aspect ratio) so that at least one dimension (width or height) of
     * the image will be equal to or less the corresponding dimension of the view.
     */
    FIT_INSIDE,
    /**
     * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the
     * image will be equal to or larger than the corresponding dimension of the view.
     */
    CROP;

    /**
     * Defines scale type of ImageView.
     *
     * @param imageView {@link ImageView}
     * @return {@link #FIT_INSIDE} for
     *         <ul>
     *         </ul>
     *         {@link #CROP} for
     *         <ul>
     *         </ul>
     */
    public static ViewScaleType fromImageView(ImageView imageView) {
        switch (imageView.getScaleType()) {
            case FIT_CENTER:
            case FIT_XY:
            case FIT_START:
            case FIT_END:
            case CENTER_INSIDE:
                return FIT_INSIDE;
            case MATRIX:
            case CENTER:
            case CENTER_CROP:
            default:
                return CROP;
        }
    }

}

